package com.gx.aut.controller;


import com.gx.aut.common.result.DataResult;
import com.gx.aut.entity.User;
import com.gx.aut.service.UserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Tag(name = "用户接口")
@RequestMapping("/api/user")
public class UserController {

    @Resource
    private UserService userService;

    @PostMapping("/addUser")
    @Schema(description = "添加用户")
    public DataResult addUser(@RequestBody @Valid User user) {
        System.out.println(user);
        userService.addUser(user);
        return DataResult.success();
    }

    @PostMapping("/findAll")
    @Schema(description = "查询所有")
    public DataResult findAllUser(){
        return DataResult.success(userService.findAllUser());
    }
}
